$(function() {
    $('[data-toggle="tooltip"]').tooltip()
    var items = $('.carousel-inner .item')
    $(window).on('resize', function() {
        var width = $(this).width()
        items.each(function(i, v) {
            if (width <= 768) {
                var src = $(this).data('smallImg')
                $(this).html($('<a class="wjs_mobileImg" href="javascript:;"> <img src=' + src + '> </a>'))
            } else {
                var src = $(this).data('bigImg')
                $(this).html($('<a class="wjs_mobilePcImg" href="javascript:;" style=" background-image: url(' + src + ')" ></a>'))
            }
        })
    }).trigger('resize')
    var startX, endX;
    var carousel_inner = $('.carousel-inner')[0]
    carousel_inner.addEventListener('touchstart', function(e) {
        startX = e.targetTouches[0].clientX
    })
    carousel_inner.addEventListener('touchend', function(e) {
        endX = e.changedTouches[0].clientX
        if (endX - startX > 0) {
            $('.carousel').carousel('prev')
        } else if (endX - startX < 0) {
            $('.carousel').carousel('next')
        }
    })

    var ulObj = $('.wjs_product ul:first-of-type')
    var lis = ulObj.find('li')
    var totalWidth = null;
    lis.each(function() {
            var liWidth = $(this).outerWidth(true)
            totalWidth += liWidth
        })
        // console.log(totalWidth)
    ulObj.width(totalWidth)


    var myScroll = new IScroll('.wapper', {
        scrollX: true,
        scrollY: false
    });
})